<?php

class Bluembo_Validate_Url extends Zend_Validate_Abstract {

    const INVALID_URL = 'invalidUrl';

    protected $_messageTemplates = array(
        self::INVALID_URL => "'%value%' is not a valid URL.",
    );

    public function isValid($value) {
        $valueString = (string) $value;
        $this->_setValue($valueString);

        try {
            $uri = Zend_Uri::factory($value, 'Bluembo_Uri_Http');
        } catch (Exception $e) {
            $this->_error(self::INVALID_URL);
            return false;
        }

        return true;
    }

}